% example of aliasing
graphsetup

N   = 8;
h   = 2*pi/N;

xh = (0:N-1)'*h;
x = 0:2*pi/100:2*pi;

figure(2)
subplot(2,1,1)
plot(xh,cos(5*xh),'r*',xh,cos(3*xh),'bp',...
     x,cos(5*x),'r-',x,cos(3*x),'b-',...
     'markersize',14)
axis([0 2*pi -1 1])
legend('cos(5x)','cos(3x)','location','NorthEast')
title('\fontsize{14} N=8  cos(5x) vs. cos(3x) ')

subplot(2,1,2)
plot(xh,sin(5*xh),'r*',xh,-sin(3*xh),'bp',...
     x,sin(5*x),'r-',x,-sin(3*x),'b-',...
     'markersize',14)
axis([0 2*pi -1 1])
legend('sin(5x)','-sin(3x)','location','SouthEast')
title('\fontsize{14} N=8 sin(5x) vs. -sin(3x) ') 

figure(3)
subplot(2,1,1)
plot(xh,cos(6*xh),'r*',xh,cos(2*xh),'bp',...
    x,cos(6*x),'r-',x,cos(2*x),'b-',...
     'markersize',14)
axis([0 2*pi -1 1])
legend('cos(6x)','cos(2x)','location','NorthEast')
title('\fontsize{14} N=8 cos(6x) vs. cos(2x) ')

subplot(2,1,2)
plot(xh,sin(6*xh),'r*',xh,-sin(2*xh),'bp',...
     x,sin(6*x),'r-',x,-sin(2*x),'b-',...
     'markersize',14)
axis([0 2*pi -1 1])
legend('sin(6x)','-sin(2x)','location','NorthWest')
title('\fontsize{14} N=8 sin(6x) vs. -sin(2x) ')







